<?php
/*
AceGame. Web browser MMORPG.
Copyright(C) 2012 Aceapps Aplicaciones. 
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses
*/

	// Session Start

	session_start();

	// Load files

	require_once '../include/functions.php';

	// Login Validation

	if (!session_validate()) {
		header('Location: ../');
		exit;
	}

	// Get session variables

	$userid = $_SESSION['id'];
	$accesslevel = $_SESSION['accesslevel'];

	// Get Selected Race

	$arraypost=array();
	foreach($_POST as $key => $value) $arraypost[]="$key";

	// Verify Race

	$query = "SELECT name FROM races WHERE id = $arraypost[0] AND playable = TRUE
		AND accesslevel <= $accesslevel";
	$result = mysql_query($query) or die(mysql_error());

	if (!mysql_num_rows($result)) {
		header('Location: index.php');
		exit;
	}

	$row = mysql_fetch_array($result);

	// Load HTML5 Template

	include_once '../template/header.php';

	echo '<form name="lrform" action="cc_do.php" method="post" accept-charset="UTF-8">
			<legend>Create '.$row[0].'</legend>
			<table width="100%">
			<tr><td>Name:</td>
			<td><input type="text" name="name" class="email" maxlength="8" required /></td></tr>
			</table>
			<input type="password" name="race" class="password" value = '.$arraypost[0].' hidden required />
			<input type="submit" value="Create" name="submit" class="submit" />
		</form>';

	// Load HTML5 Template

	include_once '../template/footer.php';
?>
